<template>
     <h2 style="text-align: center;">注册</h2>
     <table>
        <tr>
            <td>手机号</td>
            <td><input type="text" placeholder="请输入手机号" v-model="info.username"></td>
        </tr>
        <tr>
            <td>密码</td>
            <td><input type="password" placeholder="请输入密码" v-model="info.password"></td>
        </tr>
        <tr>
            <td>确认密码</td>
            <td><input type="password" placeholder="请输入密码" v-model="info.spassword"></td>
        </tr>
        <tr>
            <td colspan="2" style="text-align: center;">
             <input type="button" value="注册" @click="register">
            </td>
        </tr>
     </table>
</template>

<script setup lang="ts">
import { ref } from 'vue';

const info = ref({
    username:"",
    password:"",
    spassword:""
})


import { useRouter } from 'vue-router';

const router = useRouter();

const register = () => {
      if(info.value.username=="")
      {
        alert('手机号不能为空')
        return;
      }
      if(info.value.password=="")
      {
        alert('密码不能为空')
        return;
      }
      if(info.value.spassword=="")
      {
        alert('确认密码不能为空')
        return;
      }
      if(info.value.password!=info.value.spassword)
      {
        alert('确认密码不正确!')
        return;
      }
      if(info.value.username.length<11)
      {
        alert('密码长度不能小于11位')
        return;
      }
     if(info.value.username=="13512349876"&&info.value.password=="123456")
     {
        alert('注册成功')
        router.push({
            path:"/Admin",
            query:{
                Pid:info.value.username
            }
        })
     }
     else
     {
        alert('注册失败')
     }
}
</script>